
#include <algorithm>
#include <cmath>
#include <iostream>
#include <istream>
#include <vector>
using ll = long long;

ll n,k;

std::vector<ll> sub,a;

int main(){
    std::iostream::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

    std::cin>>n>>k;
    a.reserve(n);
    for(ll i=1;i<=n;i++){
        ll tmp;
        std::cin>>tmp;
        a.push_back(tmp);
    }
    sub.reserve(std::pow(2,n));
    for(ll msk=0;msk<(1ll<<n);msk++){
        ll nsum{};
        for(ll i=0;i<n;i++){
            if(msk&(1ll<<i)){
                nsum+=a[i];
            }
        }
        sub.push_back(nsum);
    }
    std::partial_sort(sub.begin(),sub.begin()+k,sub.end());
    for(ll i=0;i<k;i++){
        std::cout<<sub[i]<<' ';
    }
    std::cout<<'\n';
}